/**
 * IHIS 1.0 by HoneyBread (김민호, 이충희, 이성연, 신경민)
 * SEP 8기 KAIST
 */
package ihis.tms.server.service.item;

import java.util.Vector;

import ihis.core.service.RequestMessage;
import ihis.core.service.ResponseMessage;
import ihis.model.Task;
import ihis.model.TaskFilter;
import ihis.tms.server.redmine.db.TMSDatabase;
import ihis.tms.server.service.IService;

/**
 * @author minho kim
 *
 */
public class TaskListService implements IService {

	/* (non-Javadoc)
	 * @see ihis.tms.server.service.IService#run(ihis.core.service.RequestMessage)
	 */
	@Override
	public ResponseMessage run(RequestMessage requestMessage) {
		// TODO Auto-generated method stub
		ihis.model.TaskFilter filter = (TaskFilter) requestMessage.getParameter("filter");
		ResponseMessage responseMessage = new ResponseMessage();
		
		try {
			if(filter == null)
			{
				responseMessage.setOk(false);
			}
			else
			{
				Vector<Task> result = TMSDatabase.getTasks(filter);
				responseMessage.setOk(true);
				responseMessage.setResult(result);				
			}
		} catch (Exception e){
			responseMessage.setOk(false);
			e.printStackTrace();
		}
		return responseMessage;
	}

}
